
package protocol.meta;

import org.json.JSONObject;

/**
 * 资讯源
 *
 * @author MR
 */
public class Source {

    // 资讯源id
    public int sourceId;// "6793",
    // 所属的主题id
    public int subjectId;// "3143",
    // 所属主题名称
    public String subjectName;// "地下城与勇士",
    // 资讯源名称
    public String sourceName;// "新闻公告",
    // 资讯源头像
    public String avatar;// "http://nos.netease.com/buck-x1/pic/2013/05/16/18/57/26/6/60x60-综合.png",
    // 资讯页头图
    public String headImageUrl;// "http://www.sinaimg.cn/dy/slidenews/21_img/2013_12/1113_1772592_682595.jpg",
    // 资讯源描述
    public String desc;// "地下城与勇士新闻公告资讯源，为你提供最全地下城与勇士新闻公告。",
    // 资讯源订阅数
    public int subscribeCount;// 3,
    // 当前账号是否已订阅改资讯源
    public boolean isSubscribed;// false,
    // TODO 小编列表
//    public List editorList;// []

    public Source(JSONObject json) {
        if (null == json) {
            return;
        }
        sourceId = json.optInt("sourceId");
        subjectId = json.optInt("subjectId");
        subjectName = json.optString("subjectName");
        sourceName = json.optString("sourceName");
        avatar = json.optString("avatar");
        headImageUrl = json.optString("headImageUrl");
        desc = json.optString("desc");
        subscribeCount = json.optInt("subscribeCount");
        isSubscribed = json.optBoolean("isSubscribed");
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        sb.append(", subjectId:").append(subjectId)
        .append(", subjectName:").append(subjectName)
        .append(", sourceName:").append(sourceName)
        .append(", avatar:").append(avatar)
        .append(", headImageUrl:").append(headImageUrl)
        .append(", desc:").append(desc)
        .append(", subscribeCount:").append(subscribeCount)
        .append(", isSubscribed:").append(isSubscribed);
//        .append(", editorList:").append(editorList);
        sb.append("}");
        return sb.toString();
    }
}
